import {get, put, post} from "./request";
import request from "./request";

export const currentRouters = errorMessage => {
    return get("/user/cu/auth/role/current-routers", null, errorMessage);
};
export const currentRole = errorMessage => {
    return get("/user/cu/auth/role/current", null, errorMessage);
};
export const login = (
    params,
    errorMessage = {
        message: "登录失败，请重试"
    }
) => {
    return post("/user/login", params, errorMessage);
};

export const logout = (params, errorMessage) => {
    return get("/user/logout", params, errorMessage);
};

export const currentUser = (errorMessage = {}) => {
    return get("/user/cu/user/current", null, errorMessage);
};
export const fetchAllAction = (params, errorMessage) => {
    return get("/user/cu/auth/action/list", params, errorMessage);
};

export const fetchRoleAllActionCode = (params, errorMessage) => {
    return get(
        `/user/cu/auth/role/actions/${params.roleCode}`,
        params,
        errorMessage
    );
};
export const checkMobileExits = (
    params,
    errorMessage = {
        ignoreFalse: true
    }
) => {
    return get(
        `/user/cu/user/mobile-check/${params.mobile}`,
        params,
        errorMessage
    );
};

export const checkUsernameExits = (
    params,
    errorMessage = {
        ignoreFalse: true
    }
) => {
    return get(
        `/user/cu/user/username-check/${params.username}`,
        params,
        errorMessage
    );
};

export const fetchPositionList = (params, errorMessage) => {
    return get("/user/cu/admin/position/list", params, errorMessage);
};
export const fetchOwnerPositionList = (params, errorMessage) => {
    return get("/user/cu/admin/position/owner-list", params, errorMessage);
};
export const fetchRoleList = (params, errorMessage) => {
    return get("/user/cu/auth/role/s-list", params, errorMessage);
};
export const fetchRoleAnyList = (params, errorMessage) => {
    return get("/user/cu/auth/role/s-list-any", params, errorMessage);
};
export const fetchAdminUserByPositionId = (params, errorMessage) => {
    return get(
        `/user/cu/admin/user/position-admin/${params.id}`,
        params,
        errorMessage
    );
};
export const fetchUserPage = (params, errorMessage) => {
    return get("/user/cu/user/page", params, errorMessage);
};

export const savePlatformGroupConfig = (params, errorMessage) => {
    return post(`/user/sys/platform-group-config/save`, params, errorMessage);
};
export const changeGroupProcessStatus = (params, errorMessage) => {
    return post("/user/sys/group/process-change", params, errorMessage);
};

export const putUserNameForLogin = (params, errorMessage) => {
    return post("/user/cu/user/put-username-login", params, errorMessage);
};

export const fetchSchoolFirst = (params, errorMessage) => {
    return get(`/user/sys/school/getFirstStage`, params, errorMessage);
};
export const fetchOtherSchoolFirst = (params, errorMessage) => {
    return get(`/user/sys/school/other-getFirstStage`, params, errorMessage);
};
export const fetchSchoolChildren = (params, errorMessage) => {
    return get(`/user/sys/school/getChildren`, params, errorMessage);
};
export const fetchDepartmentList = (params, errorMessage) => {
    return get("/user/sys/department/s-list", params, errorMessage);
};
export const fetchFirstStageBySchoolCode = (params, errorMessage) => {
    return get(
        "/user/sys/department/getFirstStageBySchoolCode",
        params,
        errorMessage
    );
};
export const fetchDepartmentChildren = (params, errorMessage) => {
    return get("/user/sys/department/getChildren", params, errorMessage);
};
export const bindDepartment = (params, errorMessage) => {
    return post("/user/sys/department/bind", params, errorMessage);
};
export const getMenuList = (params, errorMessage) => {
    return get("/user/sys/menu/list", params, errorMessage);
};
export const getActivityList = (params, errorMessage) => {
    return get("/user/sys/activity/list", params, errorMessage);
};
export const fetchAgentLevelList = (params, errorMessage) => {
    return get("/user/cu/agent/level/list", params, errorMessage);
};
export const fetchAgentDetailAndDiscount = (params, errorMessage) => {
    return get(
        `/user/sys/agent/getDetailAndDiscount/${params.id}`,
        params,
        errorMessage
    );
};
export const fetchAgentUserSimpleDetail = (params, errorMessage) => {
    return get(
        `/user/cu/agent/user/simpleDetail/${params.id}`,
        params,
        errorMessage
    );
};
export const fetchAgentDetail = (params, errorMessage) => {
    return get(`/user/sys/agent/detail/${params.id}`, params, errorMessage);
};
export const getAgentList = (params, errorMessage) => {
    return get("/user/sys/agent/list", params, errorMessage);
};
export const getCurrentUserAgent = (params, errorMessage) => {
    return get(
        "/user/cu/agent/user/current-agentAndDiscount",
        params,
        errorMessage
    );
};
export const updateHotword = (params, errorMessage) => {
    return put(`/user/sys/hot-word/update`, params, errorMessage);
};
export const getPlateformList = (params, errorMessage) => {
    return get("/user/sys/platform/list", params, errorMessage);
}
export const getAgentUserList = (params, errorMessage) => {
    return get("/user/cu/agent/user/u-list", params, errorMessage);
}
export const getAgentOrderMoneyList = (params, errorMessage) => {
    return get("/order/or/order/agent/money", params, errorMessage);
}
export const getDetaiListByTypeCode = (params, errorMessage) => {
    return get("/user/sys/dict/detail/listByTypeCode", params, errorMessage);
}
export const getUserBankList = (params, errorMessage) => {
    return get("/user/cu/bank/list", params, errorMessage);
}
export const doSettle = (params, errorMessage) => {
    return post("/order/or/commission/doSettle", params, errorMessage);
}
export const getCommissionMoney = (params, errorMessage) => {
    return get("/order/or/commission/money", params, errorMessage);
}
export const fetchUserSimpleDetail = (params, errorMessage) => {
    return get(`/user/cu/user/detail/simple/${params.id}`, params, errorMessage);
};
export const checkGroupIpExist = (params, errorMessage) => {
    return get(`/user/sys/group/ip/check`, params, errorMessage);
}
export const batchCheckGroupIpExist = (params, errorMessage) => {
    return get(`/user/sys/group/ip/batch-check`, params, errorMessage);
}
export const checkGroupLocationExist = (params, errorMessage) => {
    return get(`/user/sys/group/location/check`, params, errorMessage);
}
export const checkGroupBatchLocationExist = (params, errorMessage) => {
    return get(`/user/sys/group/location/batch-check`, params, errorMessage);
}
export const unBindIp = (params, errorMessage) => {
    return put(`/user/sys/group/ip/unBind`, params, errorMessage);
};
export const unBindGroupAdmin = (params, errorMessage) => {
    return put(`/user/sys/group/groupAdmin/unBind`, params, errorMessage);
};
export const unBindGroupMember = (params, errorMessage) => {
    return put(`/user/cu/member/unBind`, params, errorMessage);
};
export const upGroupMemberExpireTime = (params, errorMessage) => {
    return put(`/user/cu/member/updateExpireDateBack`, params, errorMessage);
};
export const reBindGroupMember = (params, errorMessage) => {
    return put(`/user/cu/member/reBindBack`, params, errorMessage);
};
export const unBindLocation = (params, errorMessage) => {
    return put(`/user/sys/group/location/unBind`, params, errorMessage);
};
export const reBindIp = (params, errorMessage) => {
    return put(`/user/sys/group/ip/reBind`, params, errorMessage);
};
export const reBindLocation = (params, errorMessage) => {
    return put(`/user/sys/group/location/reBind`, params, errorMessage);
};
export const getGroupList = (params, errorMessage) => {
    return get("/user/sys/group/list", params, errorMessage);
};

export const getGroupDetail = (params, errorMessage) => {
    return get(`/user/sys/group/detail/${params.id}`, params, errorMessage);
};
export const getGroupIdPermission = (params, errorMessage) => {
    return get(`/user/sys/group/getPermissionByGroupId/${params.id}`, params, errorMessage);
};
export const updateGroupPermission = (params, errorMessage) => {
    return put(`/user/sys/group/permission/update`, params, errorMessage);
};
export const exportGroup = (params, errorMessage) => {
    return get(`/user/sys/group/export`, params, errorMessage);
};

export const checkHealth = (params, errorMessage) => {
    return get(`/check-health`, params, errorMessage);
};


export function uploadQrCode(url, data, errorMsg) {
    return post(url, data, errorMsg)
}

export function syncAgentUser() {
    return get(`/user/cu/agent/user/sync-agent-to-distribute`, {}, "同步失败");
}

export function getDistributionUsersTree(params) {
    return get(`/user/distributionUser/tree`, params, "获取失败");
}

export function deleteDistributionUser(id) {
    return request.delete(`/user/distributionUser`, {id}, "删除失败");
}

export function disableDistributionUser(id) {
    return post(`/user/distributionUser/disabled`, {agentId: id}, "删除失败");
}

// export function distributionRegister(){
//     return post(`/user/distribute/register`, {}, "注册失败");
// }

export function distributionRegister(params) {
    return post("/user/cu/admin/user/edit/add", params, "注册失败");
}
export function getActive(params){
    return get("/user/active-count", params, "获取失败");
}
